import request from '@/utils/request';

export type PolicyInfoMaterialVo = {
  id: number;
  title: string;
  fileName: string;
  url: string;
  matterId: number;
  isDelete: string;
};

export type MatterVo = {
  id: number;
  title: string;
  code: string;
  orgId: number;
  orgName: string;
  policyBasisUrl: string;
  policyBasisFilename: string;
  declareCondition: string;
  rewardStandard: string;
  declareStartTime: string;
  declareEndTime: string;
  explainDept: string;
  contactDetails: string;
  processingTime: string;
  processTimeLimit: string;
  isOnline: string;
  matterStatus: string;
  publishTime: string;
  publishPerson: number;
  publishPersonName: string;
  accessCount: number;
  createTime: string;
  updateTime: string;
  policyInfoDeclareMaterials: PolicyInfoMaterialVo[];
  isDelete: string;
};

// 首页-政策公告-8条通知公告
export async function getEightPolicyAnnouncement(params: any): Promise<any> {
  return request(`/portal/findNewByTitle`, {
    method: 'GET',
    params,
  });
}
// 政策公告-通知公告-分页
export async function getPolicyAnnouncement(data: any): Promise<any> {
  return request(`/portal/findNewByCondition`, {
    method: 'POST',
    data,
  });
}
// 首页-政策公告-8条最新政策
export async function getEightLatestPolicy(params: any): Promise<any> {
  return request(`/portal/getPolicyInfoForFrontPage`, {
    method: 'POST',
    params,
  });
}
// 政策公告-最新政策-分页
export async function getLatestPolicy(data: any): Promise<any> {
  return request(`/portal/getPageByConditionForFront`, {
    method: 'POST',
    data,
  });
}
// 首页-查询5条热门新闻
export async function getHotNews(params: any): Promise<any> {
  return request(`/portal/findHotNew`, {
    method: 'GET',
    params,
  });
}
// 首页-查询banner
export async function getBanner(params: any): Promise<any> {
  return request(`/portal/getBanner`, {
    method: 'GET',
    params,
  });
}
// 业务部门下拉选
// 所有部门
export async function getSelectBusinessDept(params: any): Promise<any> {
  return request(`/portal/findPolicyOrgs`, {
    method: 'GET',
    params,
  });
}
// 主管部门
export async function getSelectCompetentAuthority(params: any): Promise<any> {
  return request(`/portal/findPolicyOrgsByOrgType`, {
    method: 'GET',
    params,
  });
}
// 首页-在线申请（查询事项分页）
export async function getOnlineApplication(data: any): Promise<any> {
  return request(`/portal/findMatterByCondition`, {
    method: 'POST',
    data,
  });
}
// 查询事项详情
export async function getMatterDetail(params: any): Promise<any> {
  return request(`/portal/findMatterById`, {
    method: 'GET',
    params,
  });
}
// 首页-结果公示
export async function getResultPublicity(data: any): Promise<any> {
  return request(`/portal/getPolicyInfoApplyMatterByCondition`, {
    method: 'POST',
    data,
  });
}
// 查询新闻详情
export async function findPolicyInfoNewsById(params: any): Promise<any> {
  return request(`/policyInfoNews/findPolicyInfoNewsById`, {
    method: 'GET',
    params: { ...params },
  });
}

// 获取政策申报详情
export async function findMatterById(params: any): Promise<any> {
  return request(`/portal/findMatterById`, {
    method: 'GET',
    params,
  });
}

export async function createPolicyInfoApplyMatter(data: any): Promise<any> {
  return request.post(`/policyInfoApplyMatter/createPolicyInfoApplyMatter`, {
    data,
  });
}

// 审批公示
export async function getPolicyResultData(data: any) {
  return request(`/portal/getPolicyResultByCondition`, {
    method: 'POST',
    data,
  });
}

export async function getPolicyOrgs() {
  return request(`/portal/findPolicyOrgs`, {
    method: 'GET',
  });
}

export interface StatisticsData {
  awardedEnterprisesCount: number;
  policyMatterCount: number;
  rewardAmount: number;
  workVolume: number;
  year: string;
}

export async function getIndexStatistics() {
  return request(`/portal/getIndexStatistics`, {
    method: 'POST',
  });
}
